Class Nur.MNISV3.NodeHandleRec Extends %Persistent
{

/// 操作日期
Property WorkDate [ InitialExpression = {+$p($h,",",1)}, Required ];

/// 操作时间
Property WorkTime As %Library.Time [ InitialExpression = {+$p($h,",",2)}, Required ];

/// 操作人 
Property WorkUser As %Library.String(TRUNCATE = 1) [ SqlColumnNumber = 4 ];

/// 操作医嘱
Property WorkOeoreId As %String(TRUNCATE = 1);

/// 操作类型
Property WorkType As %String(TRUNCATE = 1);

/// 操作地点 
Property WorkPlace As %String(TRUNCATE = 1);

/// 操作时科室
Property WorkLoc As %String(TRUNCATE = 1);

/// 操作IP
Property WorkIP As %String(TRUNCATE = 1);

Index Date On WorkDate;

Index UserDate On (WorkUser, WorkDate);

Index LocDate On (WorkLoc, WorkDate);

Index Oeore On (WorkOeoreId, WorkPlace);

Index OeoreDate On (WorkOeoreId, WorkDate, WorkTime, WorkPlace);

/// w ##class(Nur.MNISV3.NodeHandleRec).Save("WorkIP|^WorkPlace|PDA","","10211","151","616||7||1","PDA")
ClassMethod Save(parr As %String, id As %String, userId As %String, locId As %String, oeoreId As %String, workType As %String) As %String
{
	s tmp=""
	s a=##class(Nur.MNISV3.Common.Utils).setmoudtmp(parr,.tmp)
	i (id=""){
		s rec=##class(Nur.MNISV3.NodeHandleRec).%New()
	}else{
		s rec=##class(Nur.MNISV3.NodeHandleRec).%OpenId(id)
	}
	i '$d(tmp("WorkDate"))  d
	.s tmp("WorkDate")=+$h
	i '$d(tmp("WorkTime"))  d
	.s tmp("WorkTime")=$p($h,",",2)
	
	i $d(tmp("WorkDate")) s rec.WorkDate=tmp("WorkDate")
	i $d(tmp("WorkTime")) s rec.WorkTime=tmp("WorkTime")
	i $d(tmp("WorkPlace")) s rec.WorkPlace=tmp("WorkPlace")
	i $d(tmp("WorkIP")) s rec.WorkIP=tmp("WorkIP")
	s rec.WorkType=workType
	s rec.WorkOeoreId=oeoreId
	s rec.WorkLoc=locId
	s rec.WorkUser=userId
	
	s sc=rec.%Save()
	s id=rec.%Id()
	d rec.%Close()
	q:$$$ISERR(sc) "err:"_$SYSTEM.Status.GetErrorText(sc)
	q id
}

/// Creator:      lmm
/// CreatDate:    2019-11-13
/// Description:  工作量删除
/// Input：       id:id,userId:用户ID
/// other:		  w ##class(Nur.MNIS.Service.DHCNurIPExeWorkLoad).Delete()
ClassMethod Delete(id As %String, userId As %String) As %String
{
	q:id="" "err:"_"id为空"
	s rec=##class(Nur.MNISV3.NodeHandleRec).%OpenId(id)
	s sc=rec.%Delete()	
	q:$$$ISERR(sc) "err:"_$SYSTEM.Status.GetErrorText(sc)
	q 0
}

Storage Default
{
<Data name="NodeHandleRecDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>WorkDate</Value>
</Value>
<Value name="3">
<Value>WorkTime</Value>
</Value>
<Value name="4">
<Value>WorkUser</Value>
</Value>
<Value name="5">
<Value>WorkOeoreId</Value>
</Value>
<Value name="6">
<Value>WorkType</Value>
</Value>
<Value name="7">
<Value>WorkPlace</Value>
</Value>
<Value name="8">
<Value>WorkLoc</Value>
</Value>
<Value name="9">
<Value>WorkIP</Value>
</Value>
</Data>
<DataLocation>^Nur.MNISV3.NodeHandleRecD</DataLocation>
<DefaultData>NodeHandleRecDefaultData</DefaultData>
<IdLocation>^Nur.MNISV3.NodeHandleRecD</IdLocation>
<IndexLocation>^Nur.MNISV3.NodeHandleRecI</IndexLocation>
<StreamLocation>^Nur.MNISV3.NodeHandleRecS</StreamLocation>
<Type>%Storage.Persistent</Type>
}

}
